#pragma once

/// <summary>
/// SysFrustumCull: Responsible for updating the contents of instanced buffers by determining which
/// instances are visible in the scene. Also draws the visible instances to the back buffer.
/// <summary>

/**	Author: Dane Bulat
  * Created: 06/2013
  * Last Modified: 30/06/2013
  * Version: v1.0
  */

#include "InstanceMap.h"
#include "ModelData.h"
#include "Camera.h"
#include "InstancedShader.h"

class SysFrustumCull
{
public:
//==============================
// Public Interface Methods
//==============================

	/**
	  * CullInstanceMaps
	  *
      * Culls instances in all instance maps that are not visible to the camera.
	  * @param Pointer to D3D Device Context.
	  * @param Reference to the vector of instance maps.
	  * @param Reference to the vector of model data objects.
	  * @param Pointer to a camera.
	  */
	 static void CullInstanceMaps(ID3D11DeviceContext* dc, vector<InstanceMap*>& instanceMaps,
		 vector<ModelData*>& modelData, Camera* pCamera);

	 /**
	  * DrawInstances
	  *
      * Draws visible instances of an instance map to the back buffer.
	  * @param Pointer to D3D Device Context.
	  * @param Pointer to an instance map.
	  * @param Pointer to a model data object.
	  * @param Pointer to a camera.
	  * @param Pointer to a material to send to the shader.
	  */
	  static void DrawInstances(ID3D11DeviceContext* deviceContext, InstanceMap* instanceMap,
		 ModelData* modelData, Camera* pCamera, Material* pMaterial);

private:
//==============================
// Constructors / Destructors
//==============================
	SysFrustumCull();
	SysFrustumCull(const SysFrustumCull& rhs);
	~SysFrustumCull();

//==============================
// Private Methods
//==============================

	/**
	  * CullInstances
	  *
      * Draws visible instances of an instance map to the back buffer.
	  * @param Pointer to D3D Device Context.
	  * @param Pointer to an instance map.
	  * @param Pointer to a model data object.
	  * @param Pointer to a camera.
	  */
	static bool CullInstances(ID3D11DeviceContext* deviceContext, InstanceMap* instanceMap, 
		 ModelData* modelData, Camera* pCamera);
};